package org.tgcloud.group.repository;

import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.tgcloud.group.entity.MjUserOrder;
import org.tgcloud.group.web.controller.dto.order.ChannelUserGoodListDTO;
import org.tgcloud.group.web.controller.dto.order.LastUserOrderDto;

import java.math.BigDecimal;
import java.util.List;

public interface MjUserOrderMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(MjUserOrder record);

    int insertSelective(MjUserOrder record);

    MjUserOrder selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(MjUserOrder record);

    int updateByPrimaryKey(MjUserOrder record);

    int updateTotalPriceById(@Param("id") Integer id, @Param("totalPrice") BigDecimal totalPrice);

    MjUserOrder selectIsHaveByOrderIdAndUserIdAndOrderType(@Param("userId") Integer userId, @Param("orderId") Integer orderId,
                                                           @Param("orderType") short orderType);

    List<ChannelUserGoodListDTO> selectListByOrderIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") short orderType, @Param("userId") Integer userId);

    List<ChannelUserGoodListDTO> selectChallengerList(@Param("orderId") Integer orderId, @Param("orderType") short orderType);

    List<ChannelUserGoodListDTO> selectListByOrderIdAndOrderTypeAndChannelUserIds(@Param("orderId") Integer orderId, @Param("orderType") short orderType, @Param("userIds") String[] userIds);

    int updateStatusByOrderIdAndUserIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") Short orderType,
                                                   @Param("userId") Integer userId, @Param("status") Short status);

    int updateIsConfirmByOrderIdAndUserIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") Short orderType,
                                                      @Param("userId") Integer userId, @Param("isConfirm") Short isConfirm);

    List<ChannelUserGoodListDTO> selectTaskListByOrderIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") short orderType);

    int updateRankByUserOrderId(@Param("userOrderId") Integer userOrderId, @Param("index") int index);

    int updateRankAndStatusByUserOrderId(@Param("userOrderId") Integer userOrderId, @Param("index") int index, @Param("status") short status);

    Integer selectNumByOrderIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") short orderType);

    ChannelUserGoodListDTO selectTopMsgByOrderIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") short orderType);

    MjUserOrder selectTaskCheckMsgByOrderIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") short orderType, @Param("status") Short status);

    MjUserOrder selectMsgByOrderIdAndOrderTypeAndRankNum(@Param("orderId") Integer orderId, @Param("orderType") short orderType, @Param("rankNum") int rankNum);

    List<MjUserOrder> selectAddListByOrderIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") short orderType);
    List<MjUserOrder> selectNoAbandonList(@Param("orderId") Integer orderId, @Param("orderType") short orderType);

    List<MjUserOrder> selectByUserId(@Param("userId") Integer userId);

    List<MjUserOrder> selectTaskCheckMsgByOrderIdAndOrderType1(@Param("orderId") Integer orderId, @Param("orderType") short orderType, @Param("status") Short status,
                                                               @Param("pushUserIds") String[] pushUserIds);

    List<MjUserOrder> selectListByOrderIdAndUserIdAndOrderType(
            @Param("orderId") Integer orderId, @Param("orderType") Short orderType,
            @Param("status") Short status);

    Integer selectUserIdByOrderIdAndOrderTypeAndRankNum(@Param("orderId") Integer orderId, @Param("orderType") Short orderType, @Param("rankNum") int rankNum);

    MjUserOrder selectMsgByOrderIdAndOrderTypeAndUserId(@Param("orderId") Integer orderId, @Param("orderType") Short orderType, @Param("firstUserId") Integer firstUserId);

    List<MjUserOrder> selectTaskListByOrderIdAndUserIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") Short orderType, @Param("userId") Integer userId);

    Integer selectCountByOrderIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") Short orderType);

    Integer selectFirstNumByOrderIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") Short orderType);

    List<MjUserOrder> selectByOrderIdAndOrderType(@Param("orderId") Integer orderId, @Param("orderType") Short orderType);

    List<MjUserOrder> selectNoConfirmList(@Param("orderId") Integer orderId, @Param("isConfirm") Short isConfirm);

    int updateAbandonByOrderIdAndUserIdAndOrderType(@Param("orderId") Integer orderId,
                                                   @Param("userId") Integer userId, @Param("isAbandon") Short isAbandon);

    MjUserOrder selectIsHaveAbandonByOrderIdAndUserIdAndOrderType(@Param("userId") Integer userId, @Param("orderId") Integer orderId,
                                                           @Param("orderType") short orderType);


    MjUserOrder selectIsHaveAbandonByOrderIdAndUserId(@Param("userId") Integer userId, @Param("orderId") Integer orderId);
    MjUserOrder selectUserByOrderIdAndOrderTypeAndRankNum(@Param("orderId") Integer orderId, @Param("orderType") Short orderType, @Param("rankNum") int rankNum);

    List<MjUserOrder> selectUserList(@Param("userIdList") List<Integer> userIdList,@Param("orderId") Integer orderId, @Param("orderType") Short orderType);
    MjUserOrder selectNoAbandonNextUser(@Param("orderId") Integer orderId);

    LastUserOrderDto selectLastUser(@Param("userId") Integer userId, @Param("orderId") Integer orderId);



}